class TruckAttributesController < ApplicationController
  def new
    @truck_attribute = TruckAttribute.new
    @truck = Truck.find(params[:truck_id])
  end

  def create
    @truck = Truck.find(params[:truck_id])

    truck_attribute = TruckAttribute.new(params[:truck_attribute])

    truck_attribute.truck_id = params[:truck_id]
    
    respond_to do |format|
      if truck_attribute.save
        format.html  { redirect_to(attributes_truck_path(@truck),
                      :notice => 'Truck property was added successfully for the truck.') }
      else
        format.html  { render :action => "new" }
      end
    end
  end

  def edit
    @truck_attribute = TruckAttribute.find(params[:id])
    @truck = Truck.find(params[:truck_id])
  end

  def update
    @truck = Truck.find(params[:truck_id])
    @truck_attribute = TruckAttribute.find(params[:id])

    respond_to do |format|
      if @truck_attribute.update_attributes(params[:truck_attribute])
        format.html  { redirect_to(attributes_truck_path(@truck),
                      :notice => 'Truck property was updated successfully for the truck.') }
      else
        format.html  { render :action => "edit" }
      end
    end
  end

  def destroy
    @truck = Truck.find(params[:truck_id])
    truck_attribute = TruckAttribute.find(params[:id])
    TruckAttribute.destroy(truck_attribute)

    respond_to do |format|
        format.html  { redirect_to(attributes_truck_path(@truck),
                      :notice => 'Truck property was deleted successfully for the truck.') }
    end
  end
end
